package com.example.oauth.authserver.repository.entity;

import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * <p>
 *
 * </p>
 *
 * @author chang.zhou
 * @version 1$
 * @date Created in 2022/3/9 12:31
 */
@Table(name = "auth_resource")
@Entity
@Data
public class Resource {
    @Id
    @GenericGenerator(name = "snowflake", strategy = "com.example.oauth.authserver.common.SnowFlakeGenerator")
    @GeneratedValue(generator = "snowflake")
    private Long id;
    @Column(name = "resource_name")
    private String resourceName;
    private String url;
    @Column(name = "http_method")
    private String httpMethod;
    @Column(name = "component_uri")
    private String componentUri;
    @Column(name = "component_name")
    private String componentName;
    private String hidden;
    private String redirect;
    @Column(name = "button_permission")
    private String buttonPermission;
    @Column(name = "resource_type")
    private Integer resourceType;
    @Column(name = "parent_id")
    private Long parentId;
    @Column(name = "group_no")
    private Integer groupNo;
    @Column(name = "sort_no")
    private Integer sortNo;
    @Column(name = "bind_to")
    private Long bindTo;
    @Column(name = "create_time")
    private LocalDateTime createTime;

    @ManyToMany(mappedBy = "resources")
    private Set<Role> roles;
}
